﻿using System;
using System.IO;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using LMSemir.DAC;
using LMSemir.Common;
namespace LMSemir.API
{
    public partial class uploadimg : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string localPath = this.Server.MapPath("~/images/temp/");
            if (!Directory.Exists(localPath))
            {
                Directory.CreateDirectory(localPath);
            }
            string tempFileName = localPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";

            HttpPostedFile file = Request.Files["Filedata"];
            if (file != null && file.ContentLength > 0)
            {
                file.SaveAs(tempFileName);

                string tempUrl = "http://" + Request.Url.Host + "/2011tees" + ImageUtils.getImageUrl(tempFileName);
                this.Response.Write(TEEUtil.generateTeeXML(1, "imgurl", tempUrl));
            }
            else
            {
                this.Response.Write(TEEUtil.generateTeeXML(-1, "error", "file is not null"));
            }
        }
    }
}